/*
	File: scenes/import_kinematic_instance.nut
	Author: Movida Production
*/

/*!
	@short	physic_test
	@author	Movida Production
*/
class	physic_test
{

	cube = 0
	clock = 0.0

	/*!
		@short	OnUpdate
		Called each frame.
	*/
	function	OnUpdate(scene)
	{
		// if unactve, active it
		if(!ItemIsActive(cube))
		{
				ItemActivate(cube, true)
			//	ItemHierarchySetInvisible(cube, false)	
		}

		clock += g_dt_frame
		ItemSetPosition(cube, Vector(cos(clock) *10.0,0.0,-10.0))
	}

	/*!
		@short	OnSetup
		Called when the scene is about to be setup.
	*/
	function	OnSetup(scene)
	{
		local group = SceneLoadAndStoreGroup(scene, "data/scenes/cube_kinematic_instance.nms", ImportFlagAll)// FlagLoadAll & ~FlagLoadGlobals)
		
//setup the item in the group
		local	items = GroupGetItemList(group)
		foreach (item in items)
		{
			ItemRenderSetup(item, g_factory)
			SceneSetupItem(scene, item)
		}

		// call the setup for this cube and be sure it's in kinematic
		cube = GroupFindItem(group, "cube")		

		ItemSetup(cube)
		ItemSetupScript(cube)
		ItemSetPhysicMode(cube, PhysicModeKinematic)		

		ItemSetPosition(cube, Vector(0.0,0.0,-10.0))
		ItemSetPosition(cube, Vector(0.0,0.0,0.0))
		ItemPhysicResetTransformation(cube, Vector(0.0,0.0,-10.0),  Vector(0.0,0.0,0.0))


		ItemActivate(cube, false)
	//s	ItemHierarchySetInvisible(cube, true)	
	}
}
